import React, { Component } from 'react'
import './index.css'

export default class Item extends Component {
  handleCheck = (id) => {
    return (e) => {
      this.props.updateTodo(id, e.target.checked)
    }
  }
  render () {
    const { id, text, done } = this.props
    return (
      <li className='todo-item'>
        <input type='checkbox' defaultChecked={done} onChange={this.handleCheck(id)} />
        <span className='todo-item__content'>{text}</span>
        <button className='todo-item-delete'>清除任务</button>
      </li>
    )
  }
}
